<!DOCTYPE HTML>
<html>

<head>
  <meta charset="utf-8">
  <title>菜鸟教程(runoob.com)</title>
 
  <script type="text/javascript">
    // 打开一个 web socket
    var ws = new WebSocket("ws://localhost:3300");

    ws.onopen = function() {
      // Web Socket 已连接上，使用 send() 方法发送数据
      ws.send("发送数据");

    };

    ws.onmessage = function(evt) {
      var received_msg = evt.data;
      console.log("数据已接收...");
    };

    ws.onclose = function() {
      console.log("连接已关闭...");
      // 关闭 websocket

    };
  </script>

</head>

<body>


</body>

</html>